package com.yfq.springframework.context.event;

import com.yfq.springframework.context.ApplicationEvent;

import java.util.Collection;

/**
 * @author: yfq
 * @date: 2023/2/1 9:20
 * @description:
 */
@SuppressWarnings("all")
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster {

    @Override
    public void multicastEvent(ApplicationEvent event) {
        //获取事件的监听者
        Collection<ApplicationListener<?>> listeners = getApplicationListener(event);

        //遍历监听者，来处理事件
        for (ApplicationListener listener : listeners) {
            listener.onApplicationEvent(event);
        }
    }
}
